.. _`Select keys in Json`: .. _`org.sysess.sympathy.selectkeysinjson`: Select keys in Json ``````````````````` .. image:: select_json.svg :width: 48 Filter a Json structure, keeping/removing keys in selected dictionaries. Documentation ::::::::::::: For more information about how to write Json queries, see :ref:`appendix_json_queries`. If :guilabel:`Match anywhere` is not checked (the default) the query must match starting at the root of the Json structure. E.g. the query ``articles`` only matches if the root entry is a dictionary containing the key "articles". Conversely, if :guilabel:`Match anywhere` is checked the query ``articles`` can matches the key "articles" in any dictionary in the whole structure. It can even match at several places despite the query just being a simple key. If the query matches anythin other than a dictionary, that entry is kept as is in the output. Modes ----- By using different modes for the :guilabel:`Keys` parameter you can achieve different behaviors. With :guilabel:`Use selected` only selected keys are kept in the output. With :guilabel:`Use and require selected` the same keys are kept in the output, but it becomes an error if any selected key is missing from any of the dictionaries. With :guilabel:`Use unselected` only keys that are *not* selected are kept in the output. Finally, with :guilabel:`Use all` all the keys are kept in the output. Definition :::::::::: Input ports ----------- **input** json Input Output ports ------------ **output** json Output Configuration ------------- **Match anywhere** (anywhere) Match the query at any position in the Json structure. **Select keys** (keys) Select keys to keep in the selected dictionaries. **Query** (query) Query for selecting entries in the Json structure. The visual editor can help you create a query which selects a single entry. The query can then be edited manually to include slices (e.g. [2:4]) or patterns (e.g. some*key) which will select multiple entries. For more details see the node's documentation. Related nodes ------------- * :ref:`org.sysess.sympathy.selectjson` * :ref:`org.sysess.sympathy.removejson` Examples -------- * :download:`json_examples.syx ` Implementation -------------- .. automodule:: node_filterjson :noindex: .. class:: SelectKeysInJson :noindex: